﻿<local:PageBase x:Class="MicroBlogClient.Comments"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
      xmlns:local="clr-namespace:MicroBlogClient"
        xmlns:controls="clr-namespace:Rabbit.Controls;assembly=Rabbit.Controls"
      mc:Ignorable="d" 
      d:DesignHeight="300" d:DesignWidth="300"
	Title="Comments">
    <local:PageBase.Resources>
        <DataTemplate x:Key="MyCommentsItemTemplate">
            <DataTemplate.Resources>
                <Storyboard x:Key="YellowFade">
                    <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="grid" Storyboard.TargetProperty="(Panel.Background).(SolidColorBrush.Color)" FillBehavior="Stop">
                        <SplineColorKeyFrame KeyTime="00:00:00" Value="#FFFEFF76" />
                        <SplineColorKeyFrame KeyTime="00:00:20" Value="#19FEFF76" />
                    </ColorAnimationUsingKeyFrames>
                </Storyboard>
            </DataTemplate.Resources>
            <DockPanel Margin="0,10,0,10" x:Name="grid" Background="Transparent">
                <!--User Picture-->
                <Border VerticalAlignment="Top" Width="40" >
                    <Border BorderBrush="White" DockPanel.Dock="Left" CornerRadius="5" Height="40" Width="40" BorderThickness="1">
                        <Image Stretch="UniformToFill"  MouseEnter="UserHeadPicture_MouseEnter"  MouseLeave="UserHeadPicture_MouseLeave" Source="{Binding User.ProfileImageUrl, Converter={StaticResource ImageConverter}, IsAsync=True}" />
                    </Border>
                </Border>
                <!--Status Text-->
                <StackPanel Margin="10,0,0,0">
                    <!--User/Status Information-->
                    <StackPanel Orientation="Horizontal">
                        <TextBlock TextWrapping="Wrap" Canvas.Top="0" Width="Auto"><Hyperlink CommandParameter="{Binding User.Id}"  Click="OpenUserPage_Click"><Run Text="{Binding User.ScreenName}"/></Hyperlink></TextBlock>
                        <ContentControl Visibility="{Binding User.Verified, Converter={StaticResource BooleanToVisibilityConverter}}" Content="{DynamicResource CertificateUser}"/>
                        <TextBlock Foreground="Gray" Margin="5,0,0,0"
                                   Visibility="{Binding IsMouseOver,Converter={StaticResource ContrastBooleanToVisibilityConverter},RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"
                                   Text="{Binding CreatedAt, Converter={StaticResource ResourceKey=DateTimeFormatConverter}, IsAsync=True}"/>
                        <TextBlock  Margin="10,0,0,0" Visibility="{Binding IsMouseOver, Converter={StaticResource BooleanToVisibilityConverter}, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}, Mode=FindAncestor}}"><Hyperlink CommandParameter="{Binding InReplyToStatusId}" Click="ReplyToCommentsHandler" ><Run Text="回复"/></Hyperlink></TextBlock>
                    </StackPanel>
                    <!--Status Inforamtion:Text and Picture(if exist)-->
                    <DockPanel Margin="10,10,0,0">
                        <!--Status text-->
                        <controls:TextBlockEx Foreground="{DynamicResource StatusForegroundBrush}"  LineHeight="20" Text="{Binding Text, IsAsync=True}" DockPanel.Dock="Top" TextWrapping="Wrap">
                            <controls:TextBlockEx.ContextMenu>
                                <ContextMenu>
                                    <MenuItem Header="复制" CommandParameter="{Binding Text}" Click="menuCopyStatus_Click"/>
                                </ContextMenu>
                            </controls:TextBlockEx.ContextMenu>
                        </controls:TextBlockEx>
                    </DockPanel>
                    <!--Reply to status information-->
                    <TextBlock Margin="10,5,0,0" ><InlineUIContainer>
                    		<Border BorderBrush="{DynamicResource FowardedStatusLeftLineBrush}" BorderThickness="1,0,0,0">
                    			<TextBlock Margin="5,0,0,0"><InlineUIContainer> 
                    					<StackPanel>
                    						<controls:TextBlockEx Padding="5,0,0,0" LineHeight="20" Foreground="{DynamicResource FowardedStatusForegroundBrush}" Text="{Binding InReplyToStatusText, IsAsync=True}"  TextWrapping="Wrap">
                    							<controls:TextBlockEx.ContextMenu>
                    								<ContextMenu>
                    									<MenuItem Header="复制" CommandParameter="{Binding InReplyToStatusText}" Click="menuCopyStatus_Click"/>
                    								</ContextMenu>
                    							</controls:TextBlockEx.ContextMenu>
                    						</controls:TextBlockEx>
                    					</StackPanel>
                    				</InlineUIContainer></TextBlock>
                    		</Border>
                    	</InlineUIContainer></TextBlock>
                    <TextBlock Margin="0,10,0,0">
                        <TextBlock Text="{Binding Source}" Foreground="Gray" />
                    </TextBlock>
                </StackPanel>
            </DockPanel>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding IsNew}" Value="true">
                    <DataTrigger.EnterActions>
                        <BeginStoryboard Storyboard="{StaticResource YellowFade}" x:Name="YellowFade_BeginStoryboard" />
                    </DataTrigger.EnterActions>
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </local:PageBase.Resources>
    <Grid>
        <ListBox Canvas.Left="0" Grid.Row="0" x:Name="lstMyCommentList" BorderThickness="0"
                                                                 ItemContainerStyle="{DynamicResource ListBoxItemStyle}"  Margin="0"
                                                                 ScrollViewer.HorizontalScrollBarVisibility="Disabled"  
                                                                 ScrollViewer.CanContentScroll="False"
                                                                 ItemTemplate="{StaticResource ResourceKey=MyCommentsItemTemplate}"
                                                                 Foreground="Black"/>
        <StackPanel VerticalAlignment="Bottom" Grid.Row="1" HorizontalAlignment="Center"  Orientation="Horizontal">
            <local:UCPager x:Name="pager" OnFirstPageClick="pager_OnFirstPageClick"
                           OnPreviousePage="pager_OnPreviousePage"
                           OnNextPageClick="pager_OnNextPageClick"/>
        </StackPanel>
    </Grid>
</local:PageBase>
